package com.hemaapp.yjnh.activity;

import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import com.hemaapp.hm_FrameWork.HemaNetTask;
import com.hemaapp.hm_FrameWork.result.HemaBaseResult;
import com.hemaapp.yjnh.BaseFragmentActivity;
import com.hemaapp.yjnh.R;
import com.hemaapp.yjnh.adapter.TabViewPagerAdapter;
import com.hemaapp.yjnh.fragment.FarmerReturnOrderListFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 田家的问题订单列表
 */
public class FarmerReturnedOrderListActivity extends BaseFragmentActivity {

    @Bind(R.id.title_left_btn)
    ImageButton titleLeftBtn;
    @Bind(R.id.title_right_btn)
    Button titleRightBtn;
    @Bind(R.id.title_text)
    TextView titleText;
    @Bind(R.id.layout_tab)
    TabLayout layoutTab;
    @Bind(R.id.viewpager)
    ViewPager viewpager;

    private FarmerReturnOrderListFragment unSolveFragment = new FarmerReturnOrderListFragment();
    private FarmerReturnOrderListFragment solvedFragment = new FarmerReturnOrderListFragment();
    private FarmerReturnOrderListFragment finishedFragment = new FarmerReturnOrderListFragment();
    private TabViewPagerAdapter pagerAdapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_custom_orders);
        ButterKnife.bind(this);
        super.onCreate(savedInstanceState);
        initDatas();
    }

    private void initDatas() {
        List<String> titles = new ArrayList<>();
        titles.add("待处理");
        titles.add("已处理");
        titles.add("已完成");
        unSolveFragment.setKeytype("1");
        solvedFragment.setKeytype("2");
        finishedFragment.setKeytype("3");
        List<Fragment> fragments = new ArrayList<>();
        fragments.add(unSolveFragment);
        fragments.add(solvedFragment);
        fragments.add(finishedFragment);
        pagerAdapter = new TabViewPagerAdapter(getSupportFragmentManager(), fragments, titles);
        viewpager.setAdapter(pagerAdapter);
        viewpager.setOffscreenPageLimit(3);
        layoutTab.setTabMode(TabLayout.MODE_FIXED);
        layoutTab.setupWithViewPager(viewpager);
        layoutTab.setTabsFromPagerAdapter(pagerAdapter);
    }

    @Override
    protected void findView() {

    }

    @Override
    protected void getExras() {
        titleText.setText("问题订单");
        titleRightBtn.setVisibility(View.GONE);
    }

    @Override
    protected void setListener() {

    }

    @Override
    protected void callBeforeDataBack(HemaNetTask hemaNetTask) {

    }

    @Override
    protected void callAfterDataBack(HemaNetTask hemaNetTask) {

    }

    @Override
    protected void callBackForServerSuccess(HemaNetTask hemaNetTask, HemaBaseResult hemaBaseResult) {

    }

    @Override
    protected void callBackForServerFailed(HemaNetTask hemaNetTask, HemaBaseResult hemaBaseResult) {

    }

    @Override
    protected void callBackForGetDataFailed(HemaNetTask hemaNetTask, int i) {

    }

    @OnClick(R.id.title_left_btn)
    public void onClick() {
        finish();
    }
}
